package com.aidong.stadium.action;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.json.annotations.JSON;
import org.springframework.beans.factory.annotation.Autowired;

import com.aidong.activity.biz.MstCampaignBiz;
import com.aidong.activity.entity.Member;
import com.aidong.stadium.biz.MstScheduleBiz;
import com.aidong.stadium.biz.MstStoreBiz;
import com.aidong.stadium.entity.MstConclusionabout;
import com.aidong.stadium.entity.MstCourseSchedule;
import com.aidong.stadium.entity.MstCourseType;
import com.aidong.stadium.entity.MstSchedule;
import com.aidong.stadium.entity.StoreCourse;
import com.aidong.util.CalendarUtil;
import com.aidong.util.CountDistance;
import com.aidong.util.PageUtil;
import com.aidong.util.ReadPropertiesUtil;
import com.aidong.util.bus.SecurityUtils;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;

/**
 * 团操action
 *
 * @author java
 * @version 1.0 2015.6.23
 */
@ParentPackage("json")
@Namespace("/")
public class MstScheduleAction implements ModelDriven<MstSchedule> {
	Logger logger = LoggerFactory.getLogger(MstScheduleAction.class);
	private MstSchedule schedule; // 团操实体类

	@Override
	public MstSchedule getModel() {
		if (schedule == null) {
			schedule = new MstSchedule();
		}
		return schedule;
	}

	@Autowired
	private MstScheduleBiz aboutScheduleBiz; // 团操service
	@Autowired
	private MstCampaignBiz mstCampaignBiz; // 活动service
	@Autowired
	private MstStoreBiz mstStoreBiz; // 场馆service

	Map<String, Object> map = new HashMap<String, Object>();

	@JSON
	public Map<String, Object> getMap() {
		return map;
	}

	/**
	 * 团操课程主页
	 *
	 * @return
	 */
	@Action(value = "getschedulehome", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getScheduleHome() {
		map = new HashMap<String, Object>();

		try {
			List<MstCourseType> typeList = new ArrayList<MstCourseType>();
			typeList.add(new MstCourseType("0", "全部", "/images/course/course-type-201511021512782.jpg"));
			Map<String, Object> maps = new HashMap<String, Object>();
			maps.put("cityId", schedule.getCityId());
			typeList.addAll(aboutScheduleBiz.getCourseType(maps));
			map.put("code", 0);
			map.put("types", typeList);
			return "succ";
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 团操课程时间安排列表
	 *
	 * @return
	 */
	@Action(value = "getscheduletimelist", results = {
			@Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getScheduleTimelist() {
		map = new HashMap<String, Object>();
		try {
			int code = schedule.getCode(); // code
			int cityId = schedule.getCityId(); // 城市ID
			int regionId = schedule.getRegionId(); // 区域ID
			int districtId = schedule.getDistrictId(); // 商圈ID
			String week = schedule.getWeek(); // 周

			int weekInt = 0;
			String month = "";
			String subDate = "";
			Map<String, Object> pageMap = PageUtil.page(20, schedule.getPageCurrent());
			if (!"".equals(week) && week != null) { // 某天的课程
				int weekDay = CalendarUtil.dataConversion(week);
				List<Map<String, Object>> dateMap = CalendarUtil.getCalenderWeek();
				for (Map<String, Object> map : dateMap) {
					String dateWeek = map.get("week").toString();
					int forWeek = CalendarUtil.dataConversion(dateWeek);
					if (weekDay == forWeek) {
						String date = map.get("dateDay").toString();

						SimpleDateFormat dateSdf = new SimpleDateFormat("yyyy年MM月dd日");
						Date forDate = dateSdf.parse(date);

						SimpleDateFormat strSdf = new SimpleDateFormat("yyyyMM");
						month = strSdf.format(forDate);

						SimpleDateFormat subSdf = new SimpleDateFormat("yyyy-MM-dd");
						subDate = subSdf.format(forDate);
						pageMap.put("classTime", subDate);
					}
				}
				pageMap.put("type", 1);
				weekInt = weekDay;
			} else { // 当天的课程
				Date date = new Date();
				Calendar calendar = new GregorianCalendar();
				calendar.setTime(date);
				calendar.add(calendar.DATE, -1);
				Date dateDay = calendar.getTime();
				Map<String, Object> dateMap = CalendarUtil.getArrangeMent(dateDay);
				week = dateMap.get("week").toString();
				weekInt = CalendarUtil.dataConversion(week);
				month = new SimpleDateFormat("yyyyMM").format(date);
				subDate = new SimpleDateFormat("yyyy-MM-dd").format(date);
				pageMap.put("classTime", subDate);
				pageMap.put("type", 1);
			}

			pageMap.put("code", code);
			pageMap.put("cityId", cityId);
			pageMap.put("regionId", regionId);
			pageMap.put("districtId", districtId);
			pageMap.put("week", weekInt);
			pageMap.put("month", month);
			pageMap.put("subDate", subDate);
			pageMap.put("classForFlg", schedule.getCarnival());

			List<MstCourseSchedule> scheduleList = aboutScheduleBiz.getScheduleTimelist(pageMap);
			for (MstCourseSchedule schedule : scheduleList) {
				Map<String, Object> paraMap = new HashMap<String, Object>();
				paraMap.put("autoId", schedule.getAutoId());
				int alreadyPerson = aboutScheduleBiz.getAppointOfPerson(paraMap);// 获取有效的报名人数
				schedule.setAlreadyPerson(alreadyPerson);
			}
			map.put("code", 1);
			map.put("result", scheduleList);
			return "succ";
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 团操课程时间安排列表
	 *
	 * @return
	 */
	@Action(value = "getscheduletimelistNew", results = {
			@Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getScheduleTimelistNew() {
		map = new HashMap<String, Object>();
		try {
			int code = schedule.getCode(); // code
			int cityId = schedule.getCityId(); // 城市ID
			int regionId = schedule.getRegionId(); // 区域ID
			int districtId = schedule.getDistrictId(); // 商圈ID
			String week = schedule.getWeek(); // 周

			int weekInt = 0;
			String month = "";
			String subDate = "";
			Map<String, Object> pageMap = PageUtil.page(20, schedule.getPageCurrent());
			if (!"".equals(week) && week != null) { // 某天的课程
				int weekDay = CalendarUtil.dataConversion(week);
				List<Map<String, Object>> dateMap = CalendarUtil.getCalenderWeek();
				for (Map<String, Object> map : dateMap) {
					String dateWeek = map.get("week").toString();
					int forWeek = CalendarUtil.dataConversion(dateWeek);
					if (weekDay == forWeek) {
						String date = map.get("dateDay").toString();

						SimpleDateFormat dateSdf = new SimpleDateFormat("yyyy年MM月dd日");
						Date forDate = dateSdf.parse(date);
						SimpleDateFormat strSdf = new SimpleDateFormat("yyyyMM");
						month = strSdf.format(forDate);
						SimpleDateFormat subSdf = new SimpleDateFormat("yyyy-MM-dd");
						subDate = subSdf.format(forDate);
						pageMap.put("classTime", subDate);
					}
				}
				pageMap.put("type", 1);
				weekInt = weekDay;
			} else { // 当天的课程
				Date date = new Date();
				Calendar calendar = new GregorianCalendar();
				calendar.setTime(date);
				calendar.add(calendar.DATE, -1);
				Date dateDay = calendar.getTime();
				Map<String, Object> dateMap = CalendarUtil.getArrangeMent(dateDay);
				week = dateMap.get("week").toString();
				weekInt = CalendarUtil.dataConversion(week);
				month = new SimpleDateFormat("yyyyMM").format(date);
				subDate = new SimpleDateFormat("yyyy-MM-dd").format(date);
				pageMap.put("classTime", subDate);
				pageMap.put("type", 2);
			}

			pageMap.put("code", code);
			pageMap.put("cityId", cityId);
			pageMap.put("regionId", regionId);
			pageMap.put("districtId", districtId);
			pageMap.put("week", weekInt);
			pageMap.put("month", month);
			pageMap.put("subDate", subDate);
			pageMap.put("classForFlg", schedule.getCarnival());
			List<MstCourseSchedule> scheduleList = aboutScheduleBiz.getScheduleTimelist(pageMap);
			for (MstCourseSchedule schedule : scheduleList) {
				Map<String, Object> paraMap = new HashMap<String, Object>();
				paraMap.put("autoId", schedule.getAutoId());
				int alreadyPerson = aboutScheduleBiz.getAppointOfPerson(paraMap);// 获取有效的报名人数
				schedule.setAlreadyPerson(alreadyPerson);
			}
			map.put("code", 1);
			map.put("result", scheduleList);
			return "succ";
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 团操课程介绍
	 *
	 * @return
	 */
	@Action(value = "getscheduleduce", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getScheduleDuce() {
		map = new HashMap<String, Object>();
		try {
			// int courseId = schedule.getCourseId(); // 课程ID
			int autoId = schedule.getAutoId(); // 团操时间ID
			int idongId = schedule.getIdongId(); // 爱动号
			// String subscribeDate = schedule.getSubscribeDate(); // 预约日期

			if (autoId > 0) {
				Map<String, Object> scDetail = new HashMap<String, Object>();
				scDetail.put("autoId", autoId);
				MstSchedule sc = aboutScheduleBiz.getSubscribeDetail(scDetail);
				String subDate = sc.getClassTime();// 预约日期

				MstConclusionabout mstConclusionabout = aboutScheduleBiz.getScheduleDuce(autoId);
				/**
				 * 获取团教教练的投票数
				 */
				Map<String, Object> voteMap = new HashMap<String, Object>();
				voteMap.put("idongId", mstConclusionabout.getIdongId());
				Map<String, Object> vote = aboutScheduleBiz.getVoteByCaochId(voteMap);
				if (vote != null) {
					mstConclusionabout.setVote(Integer.parseInt(vote.get("vote").toString()));
				}
				if (mstConclusionabout != null) {
					if (mstConclusionabout.getSubFlg() == 0 || mstConclusionabout.getSubFlg() == 2) {// 该课程需要预约,因为加入缓存的原因，需对可预约的项目进行重新判断
						String startTime = mstConclusionabout.getStartTime();
						String endTime = mstConclusionabout.getEndTime();
						if (!StringUtils.isBlank(startTime) && !StringUtils.isBlank(endTime)) {
							startTime = subDate + " " + startTime;
							endTime = subDate + " " + endTime;
							Date current = new Date();
							SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
							Date beginTime = sdf.parse(startTime);
							// 最早预约时间
							Calendar date = Calendar.getInstance();
							date.setTime(beginTime);
							date.set(Calendar.DATE, -(mstConclusionabout.getAheadSchedule() + 1));
							String earlyDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime());
							String sysSubDate = sdf.format(current);
							if (current.before(beginTime) && sysSubDate.compareTo(earlyDate) >= 0) {
								mstConclusionabout.setSubFlg(2);// 可预约
							} else {
								mstConclusionabout.setSubFlg(3);// 预约已结束
							}
						}
					}
				}
				// 因为缓存原因做此判断，如已关注无须再查询数据库
				Map<String, Object> paraMap = new HashMap<String, Object>();
				paraMap.put("idongId", idongId); // 关注人
				paraMap.put("tionIdongId", mstConclusionabout.getIdongId()); // 被关注人
				int attionCount = mstCampaignBiz.getIfAttention(paraMap);
				if (attionCount > 0) {
					mstConclusionabout.setAttionStatus(1);
				} else {
					mstConclusionabout.setAttionStatus(2);
				}
				// 已报名列表
				Map<String, Object> alreMap = new HashMap<String, Object>();
				alreMap.put("autoId", autoId);
				alreMap.put("subDate", sc.getClassTime());
				// alreMap.put("subDate", schedule.getSubscribeDate());
				// alreMap.put("subDate", mstConclusionabout.getClassTime());
				List<Map<String, Object>> details = aboutScheduleBiz.getCourseAboutDetail(alreMap);
				mstConclusionabout.setAlreadyPerson(aboutScheduleBiz.getCourseAboutCount(alreMap));
				for (Map<String, Object> map : details) {
					map.put("headUrl", ReadPropertiesUtil.getIMGREAD(map.get("headUrl")));
				}
				mstConclusionabout.setApplyPerson(details);
				map.put("code", 1);
				map.put("result", mstConclusionabout);
				return "succ";
			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 团操课程介绍
	 *
	 * @return
	 */
	@Action(value = "getscheduleduceNew", results = {
			@Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getScheduleDuceNew() {
		map = new HashMap<String, Object>();
		try {
			int autoId = schedule.getAutoId(); // 团操时间ID
			int idongId = schedule.getIdongId();
			// String subscribeDate = schedule.getSubscribeDate(); // 预约日期
			if (autoId > 0) {
				Map<String, Object> scDetail = new HashMap<String, Object>();
				scDetail.put("autoId", autoId);
				MstSchedule sc = aboutScheduleBiz.getSubscribeDetail(scDetail);
				String subDate = sc.getClassTime();// 预约日期

				MstConclusionabout mstConclusionabout = aboutScheduleBiz.getScheduleDuce(autoId);
				if (mstConclusionabout.getSubFlg() == 0 || mstConclusionabout.getSubFlg() == 5) {
					if (idongId > 0) {
						/*
						 * 判断是否登录 如果登录则根据爱动号，团操时间ID查询该用户是否已经预约
						 * 
						 */
						Map<String, Object> subMap = new HashMap<String, Object>();
						subMap.put("autoId", autoId);
						subMap.put("idongId", idongId);
						Map<String, Object> concleMap = aboutScheduleBiz.getConclusByIdongId(subMap);
						// 已预约
						if (concleMap != null) {
							int status = Integer.parseInt(concleMap.get("status").toString());
							int orderId = Integer.parseInt(concleMap.get("orderId").toString());
							int subscribeId = Integer.parseInt(concleMap.get("subscribeId").toString());
							map.put("orderId", orderId);
							map.put("subscribeId", subscribeId);
							map.put("userName", concleMap.get("userName").toString());
							map.put("phone", concleMap.get("phone").toString());
							List<Map<String, Object>> payInfo = getPayInfo(aboutScheduleBiz.getPayInfo(autoId));
							map.put("zhifubao", payInfo.get(0).get("zhifubao"));
							map.put("weixin", payInfo.get(1).get("weixin"));
							map.put("voucher", payInfo.get(2).get("voucher"));
							map.put("exchange", payInfo.get(3).get("exchange"));
							map.put("membership", payInfo.get(4).get("membership"));
							map.put("discount", payInfo.get(5).get("discount"));
							if (status == 1) {
								mstConclusionabout.setSubFlg(4);// 已支付
							} else {
								mstConclusionabout.setSubFlg(5);// 未支付
							}
						} else {
							mstConclusionabout.setSubFlg(0);
						}
					} else {
						mstConclusionabout.setSubFlg(0);
					}
				}

				if (mstConclusionabout.getSubFlg() == 0 || mstConclusionabout.getSubFlg() == 2) {// 该课程需要预约,因为加入缓存的原因，需对可预约的项目进行重新判断
					// 上课时间
					String startTime = mstConclusionabout.getStartTime();
					startTime = subDate + " " + startTime;
					// 下课时间
					String endTime = mstConclusionabout.getEndTime();
					endTime = subDate + " " + endTime;

					Date current = new Date();
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
					Date beginTime = sdf.parse(startTime);

					if (current.getTime() < sdf.parse(mstConclusionabout.getEarlyDate()).getTime()) {
						mstConclusionabout.setSubFlg(7);
					} else {
						if (current.getTime() < beginTime.getTime()) {
							mstConclusionabout.setSubFlg(2);// 可预约
						} else {
							mstConclusionabout.setSubFlg(3);// 预约已结束
						}
					}
				}
				// 因为缓存原因做此判断，如已关注无须再查询数据库
				Map<String, Object> paraMap = new HashMap<String, Object>();
				paraMap.put("idongId", idongId); // 关注人
				paraMap.put("tionIdongId", mstConclusionabout.getIdongId()); // 被关注人
				int attionCount = mstCampaignBiz.getIfAttention(paraMap);
				if (attionCount > 0) {
					mstConclusionabout.setAttionStatus(1);
				} else {
					mstConclusionabout.setAttionStatus(2);
				}
				// 已报名列表
				Map<String, Object> alreMap = new HashMap<String, Object>();
				alreMap.put("autoId", autoId);
				alreMap.put("subDate", sc.getClassTime());
				// alreMap.put("subDate", schedule.getSubscribeDate());
				// alreMap.put("subDate", mstConclusionabout.getClassTime());
				List<Map<String, Object>> details = aboutScheduleBiz.getCourseAboutDetail(alreMap);
				mstConclusionabout.setAlreadyPerson(aboutScheduleBiz.getCourseAboutCount(alreMap));
				for (Map<String, Object> map : details) {
					map.put("headUrl", ReadPropertiesUtil.getIMGREAD(map.get("headUrl")));
				}
				mstConclusionabout.setApplyPerson(details);
				if (mstConclusionabout.getAlreadyPerson() == mstConclusionabout.getAllowPerson()
						&& (mstConclusionabout.getSubFlg() == 0 || mstConclusionabout.getSubFlg() == 2)) {
					mstConclusionabout.setSubFlg(6);// 報名人數已滿
				}
				map.put("code", 1);
				map.put("result", mstConclusionabout);
				return "succ";
			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 添加团操课程预约
	 *
	 * @return
	 */
	@Action(value = "addcourseappoint", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String addCourseAppoint() {
		map = new HashMap<String, Object>();
		try {
			// 解密爱动号
			schedule.setIdongId(SecurityUtils.decryptIdongId(schedule.getIdongIdEncrypt())); // 爱动号
			Map<String, Object> subsc = new HashMap<String, Object>();
			subsc.put("autoId", schedule.getAutoId());
			MstSchedule subscribe = aboutScheduleBiz.getSubscribeDetail(subsc);

			schedule.setAutoId(subscribe.getAutoId());
			schedule.setStoreId(subscribe.getStoreId());
			schedule.setCourseId(subscribe.getCourseId());
			schedule.setSubscribeDate(subscribe.getSubscribeDate());

			int idongId = schedule.getIdongId(); // 爱动号
			int courseId = schedule.getCourseId(); // 课程ID
			int storeId = schedule.getStoreId(); // 门店ID
			int autoId = schedule.getAutoId(); // 团操时间ID
			String contactName = schedule.getContactName(); // 联系人姓名
			// 解密联系人电话
			String contactPhoneEncrypt = schedule.getContactPhoneEncrypt();
			schedule.setContactPhone(SecurityUtils.decryptPhoneNo(contactPhoneEncrypt));
			String contactPhone = schedule.getContactPhone(); // 联系人电话
			String subscribeDate = schedule.getSubscribeDate(); // 预约日期

			if (storeId > 0 && courseId > 0 && autoId > 0 && (!"".equals(contactName) && contactName != null)
					&& (!"".equals(contactPhone) && contactPhone != null)
					&& (!"".equals(subscribeDate) && subscribeDate != null)) {
				SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd HH:mm");
				Date beginSubDate = dft.parse(subscribeDate);
				subscribeDate = CalendarUtil.courseDateFomat(subscribeDate);
				schedule.setSubscribeDate(subscribeDate); // 预约日期
				Date current = new Date();
				if (beginSubDate.getTime() > current.getTime()) {
					map.put("code", 0);
					map.put("msg", "该课程暂时不能预约");
					return "succ";
				}

				// 所有课程只能提前十五分钟预约
				String sysDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
				long minutes = CalendarUtil.fromDateStringToLong(sysDate, subscribeDate); // 预约时间
				System.out.println(Math.abs(minutes));
				if (Math.abs(minutes) < 15 ) {
					map.put("code", 0);
					map.put("msg", "该课程需提前15分钟预约");
					return "succ";
				}

				// 判断该手机号码是否在该时间段预约其它课程
				Map<String, Object> otherPramMap = new HashMap<String, Object>();
				otherPramMap.put("phoneNo", contactPhone);
				otherPramMap.put("autoId", autoId);
				List<Map<String, Object>> otherMap = aboutScheduleBiz.getOtherAppoint(otherPramMap);

				for (Map<String, Object> otherCourse : otherMap) {
					String year = otherCourse.get("subscribeDate") + ""; // 年月日
					String startTime = otherCourse.get("startTime") + ""; // 课程开始时间
					String endTime = otherCourse.get("endTime") + ""; // 课程结束时间

					String courseStartTime = year + " " + startTime;
					String courseEndTime = year + " " + endTime;

					if (subscribeDate.compareTo(courseStartTime) > -1 && subscribeDate.compareTo(courseEndTime) < 1) {
						map.put("code", 0);
						map.put("msg", "您已在该时间段预约其它课程");
						return "succ";
					}
				}

				// 可预约人数
				Map<String, Object> allPersonMap = new HashMap<String, Object>();
				allPersonMap.put("courseId", courseId); // 团操课程ID
				allPersonMap.put("autoId", autoId); // 时间ID
				Map<String, Object> resultMap = aboutScheduleBiz.getAppointIfFull(allPersonMap);
				int personCount = Integer.valueOf(resultMap.get("allowPerson").toString());
				int version = Integer.valueOf(resultMap.get("version").toString());

				// 已预约人数
				Map<String, Object> paraAppointMap = new HashMap<String, Object>();
				paraAppointMap.put("courseId", courseId); // 课程ID
				paraAppointMap.put("autoId", autoId); // 时间ID
				// paraAppointMap.put("subscribeDate", subscribeDate); // 预约时间
				int alreadyPerson = aboutScheduleBiz.getAppointOfPerson(paraAppointMap);

				if (personCount <= alreadyPerson) {
					map.put("code", 0);
					map.put("msg", "预约已满，您可以选择别的课程");
					return "succ";
				} else if (personCount > alreadyPerson) {
					if (idongId > 0) { // 已登录
						// 判断该手机是否在当天已经预约该课程
						Map<String, Object> paraMap = new HashMap<String, Object>();
						paraMap.put("autoId", autoId);
						paraMap.put("idongId", idongId);
						paraMap.put("subscribeDate", subscribeDate);
						List<Map<String, Object>> alreayMap = aboutScheduleBiz.getIfAppoint(paraMap);
						if (alreayMap.size() > 0) {
							for (Map<String, Object> alreay : alreayMap) {
								int alreayStatus = Integer.parseInt(alreay.get("status").toString());
								if (alreayStatus == 0) { // 已预约
									map.put("code", 0);
									map.put("msg", "你已预约该课程，请到订单列表查看");
									return "succ";
								}
							}

							Map<String, Object> updateMap = new HashMap<String, Object>();
							updateMap.put("courseId", courseId); // 课程ID
							updateMap.put("autoId", autoId); // 时间ID
							updateMap.put("version", version); // version
							// 更新version字段
							Map<String, Object> updateResult = aboutScheduleBiz.editScheduleVersion(updateMap,
									schedule);
							if (Integer.parseInt(updateResult.get("versionResult").toString()) > 0) {
								int subscribeId = Integer.parseInt(updateResult.get("subscribeId").toString()); // 预约ID
								String orderId = updateResult.get("orderId").toString(); // 订单ID

								map.put("code", 1);
								map.put("subscribeId", subscribeId);
								map.put("orderId", orderId);
								List<Map<String, Object>> payInfo = getPayInfo(aboutScheduleBiz.getPayInfo(autoId));
								map.put("zhifubao", payInfo.get(0).get("zhifubao"));
								map.put("weixin", payInfo.get(1).get("weixin"));
								map.put("voucher", payInfo.get(2).get("voucher"));
								map.put("exchange", payInfo.get(3).get("exchange"));
								map.put("membership", payInfo.get(4).get("membership"));
								map.put("discount", payInfo.get(5).get("discount"));
								return "succ";
							} else {
								map.put("code", 0);
								map.put("msg", "当前预约人数较多，请稍后重试!");
								return "succ";
							}

						} else { // 未预约
							Map<String, Object> updateMap = new HashMap<String, Object>();
							updateMap.put("courseId", courseId); // 课程ID
							updateMap.put("autoId", autoId); // 时间ID
							updateMap.put("version", version); // version
							Map<String, Object> updateResult = aboutScheduleBiz.editScheduleVersion(updateMap,
									schedule);
							if (Integer.parseInt(updateResult.get("versionResult").toString()) > 0) {
								int subscribeId = Integer.parseInt(updateResult.get("subscribeId").toString()); // 预约ID
								String orderId = updateResult.get("orderId").toString(); // 订单ID

								map.put("code", 1);
								map.put("subscribeId", subscribeId);
								map.put("orderId", orderId);
								List<Map<String, Object>> payInfo = getPayInfo(aboutScheduleBiz.getPayInfo(autoId));
								map.put("zhifubao", payInfo.get(0).get("zhifubao"));
								map.put("weixin", payInfo.get(1).get("weixin"));
								map.put("voucher", payInfo.get(2).get("voucher"));
								map.put("exchange", payInfo.get(3).get("exchange"));
								map.put("membership", payInfo.get(4).get("membership"));
								map.put("discount", payInfo.get(5).get("discount"));
								return "succ";
							} else {
								map.put("code", 0);
								map.put("msg", "当前预约人数较多，请稍后重试!");
								return "succ";
							}

						}
					} else { // 未登录
						// 判断该手机号码是否已注册
						int count = mstCampaignBiz.getIfRegister(contactPhone);
						if (count > 0) { // 已注册
							int rsultIdongId = mstCampaignBiz.getIdongIdByPhone(contactPhone);
							schedule.setIdongId(rsultIdongId);// 将根据手机号查询出的爱动号赋值
							// 判断该手机是否在当天已经预约
							Map<String, Object> paraMap = new HashMap<String, Object>();
							paraMap.put("autoId", autoId);
							paraMap.put("idongId", rsultIdongId);
							paraMap.put("subscribeDate", subscribeDate);
							List<Map<String, Object>> alreayMap = aboutScheduleBiz.getIfAppoint(paraMap);
							if (alreayMap.size() > 0) { // 已预约
								for (Map<String, Object> alreay : alreayMap) {
									int alreayStatus = Integer.parseInt(alreay.get("status").toString());
									if (alreayStatus == 0) {
										map.put("code", 0);
										map.put("msg", "你已预约该课程，请到订单列表查看");
										return "succ";
									}
								}

								Map<String, Object> updateMap = new HashMap<String, Object>();
								updateMap.put("courseId", courseId); // 课程ID
								updateMap.put("autoId", autoId); // 时间ID
								updateMap.put("version", version); // version
								Map<String, Object> updateResult = aboutScheduleBiz.editScheduleVersion(updateMap,
										schedule);
								if (Integer.parseInt(updateResult.get("versionResult").toString()) > 0) {
									int subscribeId = Integer.parseInt(updateResult.get("subscribeId").toString()); // 预约ID
									String orderId = updateResult.get("orderId").toString(); // 订单ID

									map.put("code", 1);
									map.put("subscribeId", subscribeId);
									map.put("orderId", orderId);
									List<Map<String, Object>> payInfo = getPayInfo(aboutScheduleBiz.getPayInfo(autoId));
									map.put("zhifubao", payInfo.get(0).get("zhifubao"));
									map.put("weixin", payInfo.get(1).get("weixin"));
									map.put("voucher", payInfo.get(2).get("voucher"));
									map.put("exchange", payInfo.get(3).get("exchange"));
									map.put("membership", payInfo.get(4).get("membership"));
									map.put("discount", payInfo.get(5).get("discount"));
									return "succ";
								} else {
									map.put("code", 0);
									map.put("msg", "当前预约人数较多，请稍后重试!");
									return "succ";
								}

							} else { // 未预约

								Map<String, Object> updateMap = new HashMap<String, Object>();
								updateMap.put("courseId", courseId); // 课程ID
								updateMap.put("autoId", autoId); // 时间ID
								updateMap.put("version", version); // version
								Map<String, Object> updateResult = aboutScheduleBiz.editScheduleVersion(updateMap,
										schedule);
								if (Integer.parseInt(updateResult.get("versionResult").toString()) > 0) {
									int subscribeId = Integer.parseInt(updateResult.get("subscribeId").toString()); // 预约ID
									String orderId = updateResult.get("orderId").toString(); // 订单ID

									map.put("code", 1);
									map.put("subscribeId", subscribeId);
									map.put("orderId", orderId);
									List<Map<String, Object>> payInfo = getPayInfo(aboutScheduleBiz.getPayInfo(autoId));
									map.put("zhifubao", payInfo.get(0).get("zhifubao"));
									map.put("weixin", payInfo.get(1).get("weixin"));
									map.put("voucher", payInfo.get(2).get("voucher"));
									map.put("exchange", payInfo.get(3).get("exchange"));
									map.put("membership", payInfo.get(4).get("membership"));
									map.put("discount", payInfo.get(5).get("discount"));
									return "succ";
								} else {
									map.put("code", 0);
									map.put("msg", "当前预约人数较多，请稍后重试!");
									return "succ";
								}

							}
						} else { // 未注册
							Map<String, Object> updateMap = new HashMap<String, Object>();
							updateMap.put("courseId", courseId); // 课程ID
							updateMap.put("autoId", autoId); // 时间ID
							updateMap.put("version", version); // version
							// 记录用户信息等下注册爱动号
							Map<String, Object> regMap = new HashMap<String, Object>();
							regMap.put("contactName", contactName);
							regMap.put("contactPhone", contactPhone);

							Map<String, Object> updateResult = aboutScheduleBiz.editScheduleVersionNoSign(updateMap,
									schedule, regMap);
							if (Integer.parseInt(updateResult.get("versionResult").toString()) > 0) {
								int subscribeId = Integer.parseInt(updateResult.get("subscribeId").toString()); // 预约ID
								String orderId = updateResult.get("orderId").toString(); // 订单ID

								map.put("code", 1);
								map.put("subscribeId", subscribeId);
								map.put("orderId", orderId);
								List<Map<String, Object>> payInfo = getPayInfo(aboutScheduleBiz.getPayInfo(autoId));
								map.put("zhifubao", payInfo.get(0).get("zhifubao"));
								map.put("weixin", payInfo.get(1).get("weixin"));
								map.put("voucher", payInfo.get(2).get("voucher"));
								map.put("exchange", payInfo.get(3).get("exchange"));
								map.put("membership", payInfo.get(4).get("membership"));
								map.put("discount", payInfo.get(5).get("discount"));
								return "succ";
							} else {
								map.put("code", 0);
								map.put("msg", "当前预约人数较多，请稍后重试!");
								return "succ";
							}

						}
					}
				}
			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
			map.put("code", 0);
			map.put("msg", "暂不支持预约");
			return "succ";
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 门店下的团操课程排班表
	 *
	 * @return
	 */
	@Action(value = "getaboutschedule", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getAboutSchedule() {
		map = new HashMap<String, Object>();
		try {
			int storeId = schedule.getStoreId(); // 门店ID
			String week = schedule.getWeek(); // 周
			Map<String, Object> paraMap = new HashMap<String, Object>();
			if (storeId > 0 && (!"".equals(week) && week != null)) {
				int weekDay = CalendarUtil.dataConversion(week);
				String strDate = "";
				List<Map<String, Object>> dateMap = CalendarUtil.getCalenderWeek();

				for (Map<String, Object> map : dateMap) {
					String dateWeek = map.get("week").toString();
					int forWeek = CalendarUtil.dataConversion(dateWeek);
					if (weekDay == forWeek) {
						String date = map.get("dateDay").toString();

						SimpleDateFormat dateSdf = new SimpleDateFormat("yyyy年MM月dd日");
						Date forDate = dateSdf.parse(date);

						SimpleDateFormat strSdf = new SimpleDateFormat("yyyyMM");
						strDate = strSdf.format(forDate);
						paraMap.put("classTime", new SimpleDateFormat("yyyy-MM-dd").format(forDate));
					}
				}
				paraMap.put("storeId", storeId);
				paraMap.put("month", strDate);
				// List<Map<String, Object>> scheduleMap =
				// aboutScheduleBiz.getAboutSchedule(paraMap);
				List<StoreCourse> scheduleMap = aboutScheduleBiz.getAboutSchedule(paraMap);
				for (StoreCourse storeCourse : scheduleMap) {
					storeCourse.setCou(aboutScheduleBiz.getSchedulePerson(storeCourse.getAutoId()));
				}
				map.put("code", 1);
				map.put("result", scheduleMap);
			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
		return "succ";
	}

	/**
	 * 门店差价
	 *
	 * @return
	 */
	@Action(value = "getmststoreprice", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getMststorePriceDiffer() {
		map = new HashMap<String, Object>();
		try {
			int orderId = schedule.getOrderId(); // 订单ID
			if (orderId > 0) {
				int price = aboutScheduleBiz.getMststorePriceDiffer(orderId);
				map.put("code", 1);
				map.put("result", price);
				return "succ";
			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 课程筛选选项内容
	 *
	 * @return
	 */
	@Action(value = "getrncoursesifting", results = {
			@Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getMstCityList() {
		map = new HashMap<String, Object>();
		try {
			// 城市列表
			List<Map<String, Object>> citys = mstStoreBiz.getMstCity(schedule.getAreaId());

			// 行政区域列表
			List<Map<String, Object>> regions = new ArrayList<Map<String, Object>>();

			// 热门商圈列表
			Map<String, Object> areas = new HashMap<String, Object>();
			areas.put("areaId", "0");
			areas.put("areaName", "热门商圈");
			int weekNum = 0;
			// 热门商圈中的热门商圈
			List<Map<String, Object>> dishotMap = new ArrayList<Map<String, Object>>();

			// 热门商圈中的全部商圈
			Map<String, Object> total = new HashMap<String, Object>();
			total.put("areaId", "0");
			total.put("areaName", "全部商圈");
			dishotMap.add(total);

			List<Map<String, Object>> hots = mstStoreBiz.getMstHotDistrict(schedule.getAreaId());
			for (int i = 0; i < hots.size(); i++) {
				dishotMap.add(hots.get(i));
			}

			areas.put("district", dishotMap);

			regions.add(areas);

			for (Map<String, Object> city : citys) {
				// 区列表
				List<Map<String, Object>> regionList = mstStoreBiz.getMstRegion(city.get("areaId").toString());
				for (Map<String, Object> region : regionList) {
					// 商圈列表
					List<Map<String, Object>> districts = new ArrayList<Map<String, Object>>();

					Map<String, Object> allDis = new HashMap<String, Object>();
					allDis.put("areaId", "0");
					allDis.put("areaName", "全部商圈");
					districts.add(allDis);

					List<Map<String, Object>> listMap = mstStoreBiz.getMstDistrict(region.get("areaId").toString());
					for (int i = 0; i < listMap.size(); i++) {
						districts.add(listMap.get(i));
					}

					region.put("district", districts);
				}
				for (int i = 0; i < regionList.size(); i++) {
					regions.add(regionList.get(i));
				}
			}

			// 课程类别
			Map<String, Object> allType = new HashMap<String, Object>();
			allType.put("code", 0);
			allType.put("chName", "全部");
			allType.put("url", "");

			List<Map<String, Object>> types = new ArrayList<Map<String, Object>>();
			types.add(allType);
			List<MstCourseType> typeList = new ArrayList<MstCourseType>();
			typeList.add(new MstCourseType("0", "全部", "/images/course/course-type-201511021512782.jpg"));
			Map<String, Object> maps = new HashMap<String, Object>();
			maps.put("cityId", schedule.getCityId());
			typeList.addAll(aboutScheduleBiz.getCourseType(maps));
			// 课程时间安排
			List<Map<String, Object>> dateMap = CalendarUtil.getCalenderWeek();
			/**
			 * 新版课程日期 如果当前时间没有课程，则显示之后的数据 返回有数据的是周几
			 */
			if (schedule.getNewType() > 0) {
				Date date = new Date();
				Calendar calendar = new GregorianCalendar();
				calendar.setTime(date);
				calendar.add(calendar.DATE, -1);
				Date dateDay = calendar.getTime();
				Map<String, Object> dateNewMap = CalendarUtil.getArrangeMent(dateDay);
				String week = dateNewMap.get("week").toString();
				int weekInt = CalendarUtil.dataConversion(week);
				String month = new SimpleDateFormat("yyyyMM").format(date);
				String subDate = new SimpleDateFormat("yyyy-MM-dd").format(date);
				Map<String, Object> getWeek = new HashMap<String, Object>();
				int cityId = schedule.getCityId(); // 城市ID
				getWeek.put("classTime", subDate);
				getWeek.put("week", weekInt);
				getWeek.put("month", month);
				getWeek.put("cityId", cityId);
				getWeek.put("code", schedule.getCode());
//				Map<String, Object> result = aboutScheduleBiz.getScheduleWeek(getWeek);
//				if (result != null) {
//					if (!StringUtils.isBlank(result.get("classWeek").toString())) {
//						weekNum = Integer.parseInt(result.get("classWeek").toString());
//						if (weekNum == 1) {
//							weekNum = 7;
//						} else if (weekNum == 7) {
//							weekNum = 6;
//						} else {
//							weekNum = weekNum - 1;
//						}
//					}
//				}
			}

			Map<String, Object> resultMap = new HashMap<String, Object>();
			resultMap.put("regions", regions);
			resultMap.put("types", typeList);
			resultMap.put("arrangement", dateMap);
			resultMap.put("weekNum", weekNum);
			map.put("code", 1);
			map.put("result", resultMap);
			return "succ";
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 课程报名列表
	 *
	 * @return
	 */
	@Action(value = "getalreadysignedcourse", results = {
			@Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getAlreadySignedCourse() {
		map = new HashMap<String, Object>();
		try {
			int autoId = schedule.getAutoId(); // 时间Id
			String coordinate = schedule.getCoordinate(); // 请求经纬度
			int idongId = schedule.getIdongId(); // 爱动号
			String subscribeDate = schedule.getSubscribeDate(); // 预约日期
			if (autoId > 0 && !"".equals(subscribeDate) && subscribeDate != null) {
				Map<String, Object> paraMap = new HashMap<String, Object>();
				paraMap.put("autoId", autoId);
				List<Member> members = aboutScheduleBiz.getAlreadySignedCourse(paraMap);
				if (members.size() > 0) {
					for (Member member : members) {
						member.setHeadUrl(ReadPropertiesUtil.getIMGREAD(member.getHeadUrl()));
						double lon = member.getLon();
						double lat = member.getLat();
						if ((!"".equals(coordinate) && coordinate != null) && lon > 0 && lat > 0) {
							String[] reqNate = coordinate.split(",");
							int dis = 0; // 距离
							if (reqNate.length > 0) {
								double discance = CountDistance.distance(Double.parseDouble(reqNate[0]),
										Double.parseDouble(reqNate[1]), lon, lat);
								dis = (int) Math.rint(discance); // 四舍五入取整数
							}
							int distance = dis / 1000;
							if (distance < 1) {
								if (dis <= 100) {
									member.setCoordinate("<100m"); // 相距距离
								} else if (100 < dis && dis <= 500) {
									member.setCoordinate("<500m"); // 相距距离
								} else if (500 < dis && dis <= 800) {
									member.setCoordinate("<800m"); // 相距距离
								} else {
									member.setCoordinate(dis + " m"); // 相距距离
								}
							} else {
								member.setCoordinate(distance + " km"); // 相距距离
							}
						}
						Map<String, Object> paraMap2 = new HashMap<String, Object>();
						paraMap2.put("idongId", idongId); // 关注人
						paraMap2.put("tionIdongId", member.getIdongId()); // 被关注人
						int attionCount = mstCampaignBiz.getIfAttention(paraMap2);
						if (idongId > 0) {
							if (attionCount > 0) { // 已关注
								member.setAttionStatus("1");
							} else { // 关注
								member.setAttionStatus("2");
							}
						} else { // 关注
							member.setAttionStatus("2");
						}
					}
				} else {
					map.put("code", 0);
					map.put("msg", "暂时没有人参加报名");
					return "succ";
				}
				map.put("code", 1);
				map.put("result", members);
				return "succ";
			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 团操课程时间安排列表 十一月课程列表
	 *
	 * @return
	 */
	@Action(value = "getschedulelist", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getSchedulelist() {
		map = new HashMap<String, Object>();
		try {
			int code = schedule.getCode(); // code
			int cityId = schedule.getCityId(); // 城市ID
			int regionId = schedule.getRegionId(); // 区域ID
			int districtId = schedule.getDistrictId(); // 商圈ID
			String week = schedule.getWeek(); // 周

			int weekInt = 0;
			String month = "";
			String subDate = "";
			Map<String, Object> pageMap = PageUtil.page(20, schedule.getPageCurrent());
			if (!"".equals(week) && week != null) { // 某天的课程
				int weekDay = CalendarUtil.dataConversion(week);
				List<Map<String, Object>> dateMap = CalendarUtil.getCalenderWeekNew();
				for (Map<String, Object> map : dateMap) {
					String dateWeek = map.get("week").toString();
					int forWeek = CalendarUtil.dataConversion(dateWeek);
					if (weekDay == forWeek) {
						String date = map.get("dateDay").toString();

						SimpleDateFormat dateSdf = new SimpleDateFormat("yyyy年MM月dd日");
						Date forDate = dateSdf.parse(date);

						SimpleDateFormat strSdf = new SimpleDateFormat("yyyyMM");
						month = strSdf.format(forDate);

						SimpleDateFormat subSdf = new SimpleDateFormat("yyyy-MM-dd");
						subDate = subSdf.format(forDate);
						pageMap.put("classTime", subDate);
					}
				}
				pageMap.put("type", 1);
				weekInt = weekDay;
			} else { // 当天的课程
				Date date = new Date();
				Calendar calendar = new GregorianCalendar();
				calendar.setTime(date);
				SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
				Date time = sm.parse("2016-11-11");

				if (calendar.getTime().before(time)) {
					calendar.setTime(time);
				}
				calendar.add(calendar.DATE, -1);
				Date dateDay = calendar.getTime();
				Map<String, Object> dateMap = CalendarUtil.getArrangeMent(dateDay);
				week = dateMap.get("week").toString();
				weekInt = CalendarUtil.dataConversion(week);
				month = new SimpleDateFormat("yyyyMM").format(date);
				subDate = new SimpleDateFormat("yyyy-MM-dd").format(date);
				pageMap.put("classTime", subDate);
				pageMap.put("type", 1);
			}

			pageMap.put("code", code);
			pageMap.put("cityId", cityId);
			pageMap.put("regionId", regionId);
			pageMap.put("districtId", districtId);
			pageMap.put("week", weekInt);
			pageMap.put("month", month);
			pageMap.put("subDate", subDate);
			pageMap.put("classForFlg", schedule.getCarnival());

			List<MstCourseSchedule> scheduleList = aboutScheduleBiz.getScheduleTimelist(pageMap);
			for (MstCourseSchedule schedule : scheduleList) {
				Map<String, Object> paraMap = new HashMap<String, Object>();
				paraMap.put("autoId", schedule.getAutoId());
				int alreadyPerson = aboutScheduleBiz.getAppointOfPerson(paraMap);// 获取有效的报名人数
				schedule.setAlreadyPerson(alreadyPerson);
			}
			map.put("code", 1);
			map.put("result", scheduleList);
			return "succ";
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 课程筛选选项内容 十一月活动需要
	 *
	 * @return
	 */
	@Action(value = "getrncoursesiftingNew", results = {
			@Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getMstCityListNew() {
		map = new HashMap<String, Object>();
		try {
			// 城市列表
			List<Map<String, Object>> citys = mstStoreBiz.getMstCity(schedule.getAreaId());

			// 行政区域列表
			List<Map<String, Object>> regions = new ArrayList<Map<String, Object>>();

			// 热门商圈列表
			Map<String, Object> areas = new HashMap<String, Object>();
			areas.put("areaId", "0");
			areas.put("areaName", "热门商圈");
			int weekNum = 0;
			// 热门商圈中的热门商圈
			List<Map<String, Object>> dishotMap = new ArrayList<Map<String, Object>>();

			// 热门商圈中的全部商圈
			Map<String, Object> total = new HashMap<String, Object>();
			total.put("areaId", "0");
			total.put("areaName", "全部商圈");
			dishotMap.add(total);

			List<Map<String, Object>> hots = mstStoreBiz.getMstHotDistrict(schedule.getAreaId());
			for (int i = 0; i < hots.size(); i++) {
				dishotMap.add(hots.get(i));
			}

			areas.put("district", dishotMap);

			regions.add(areas);

			for (Map<String, Object> city : citys) {
				// 区列表
				List<Map<String, Object>> regionList = mstStoreBiz.getMstRegion(city.get("areaId").toString());
				for (Map<String, Object> region : regionList) {
					// 商圈列表
					List<Map<String, Object>> districts = new ArrayList<Map<String, Object>>();

					Map<String, Object> allDis = new HashMap<String, Object>();
					allDis.put("areaId", "0");
					allDis.put("areaName", "全部商圈");
					districts.add(allDis);

					List<Map<String, Object>> listMap = mstStoreBiz.getMstDistrict(region.get("areaId").toString());
					for (int i = 0; i < listMap.size(); i++) {
						districts.add(listMap.get(i));
					}

					region.put("district", districts);
				}
				for (int i = 0; i < regionList.size(); i++) {
					regions.add(regionList.get(i));
				}
			}

			// 课程类别
			Map<String, Object> allType = new HashMap<String, Object>();
			allType.put("code", 0);
			allType.put("chName", "全部");
			allType.put("url", "");

			List<Map<String, Object>> types = new ArrayList<Map<String, Object>>();
			types.add(allType);
			List<MstCourseType> typeList = new ArrayList<MstCourseType>();
			typeList.add(new MstCourseType("0", "全部", "/images/course/course-type-201511021512782.jpg"));
			Map<String, Object> maps = new HashMap<String, Object>();
			maps.put("cityId", schedule.getCityId());
			typeList.addAll(aboutScheduleBiz.getCourseType(maps));
			// 课程时间安排
			List<Map<String, Object>> dateMap = CalendarUtil.getCalenderWeekNew();
			/**
			 * 新版课程日期 如果当前时间没有课程，则显示之后的数据 返回有数据的是周几
			 */
			if (schedule.getNewType() > 0) {
				Date date = new Date();
				Calendar calendar = new GregorianCalendar();
				calendar.setTime(date);
				calendar.add(calendar.DATE, -1);
				Date dateDay = calendar.getTime();
				Map<String, Object> dateNewMap = CalendarUtil.getArrangeMent(dateDay);
				String week = dateNewMap.get("week").toString();
				int weekInt = CalendarUtil.dataConversion(week);
				String month = new SimpleDateFormat("yyyyMM").format(date);
				String subDate = new SimpleDateFormat("yyyy-MM-dd").format(date);
				Map<String, Object> getWeek = new HashMap<String, Object>();
				int cityId = schedule.getCityId(); // 城市ID
				getWeek.put("classTime", subDate);
				getWeek.put("week", weekInt);
				getWeek.put("month", month);
				getWeek.put("cityId", cityId);
				getWeek.put("code", schedule.getCode());
				Map<String, Object> result = aboutScheduleBiz.getScheduleWeek(getWeek);
				if (result != null) {
					if (!StringUtils.isBlank(result.get("classWeek").toString())) {
						weekNum = Integer.parseInt(result.get("classWeek").toString());
						if (weekNum == 1) {
							weekNum = 7;
						} else if (weekNum == 7) {
							weekNum = 6;
						} else {
							weekNum = weekNum - 1;
						}
					}
				}
			}

			Map<String, Object> resultMap = new HashMap<String, Object>();
			resultMap.put("regions", regions);
			resultMap.put("types", typeList);
			resultMap.put("arrangement", dateMap);
			resultMap.put("weekNum", weekNum);
			map.put("code", 1);
			map.put("result", resultMap);
			return "succ";
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	// 得到支付信息
	public List<Map<String, Object>> getPayInfo(String payInfo) {
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		Map<String, Object> zhifubao = new HashMap<String, Object>();
		Map<String, Object> weixin = new HashMap<String, Object>();
		Map<String, Object> voucher = new HashMap<String, Object>();
		Map<String, Object> exchange = new HashMap<String, Object>();
		Map<String, Object> membership = new HashMap<String, Object>();
		Map<String, Object> discount = new HashMap<String, Object>();
		if (payInfo.contains("1")) {
			zhifubao.put("zhifubao", true);
			result.add(zhifubao);
		} else {
			zhifubao.put("zhifubao", false);
			result.add(zhifubao);
		}
		if (payInfo.contains("2")) {
			weixin.put("weixin", true);
			result.add(weixin);
		} else {
			weixin.put("weixin", false);
			result.add(weixin);
		}
		if (payInfo.contains("3")) {
			voucher.put("voucher", true);
			result.add(voucher);
		} else {
			voucher.put("voucher", false);
			result.add(voucher);
		}
		if (payInfo.contains("4")) {
			exchange.put("exchange", true);
			result.add(exchange);
		} else {
			exchange.put("exchange", false);
			result.add(exchange);
		}
		if (payInfo.contains("5")) {
			membership.put("membership", true);
			result.add(membership);
		} else {
			membership.put("membership", false);
			result.add(membership);
		}
		if (payInfo.contains("6")) {
			discount.put("discount", true);
			result.add(discount);
		} else {
			discount.put("discount", false);
			result.add(discount);
		}
		return result;
	}
}